//
//  UIImageView+ImageSize.m
//  QRMaster
//
//  Created by myApple on 16/5/29.
//  Copyright © 2016年 myApple. All rights reserved.
//

#import "UIImageView+ImageSize.h"
#import <objc/runtime.h>

@implementation UIImageView (ImageSize)

static char UIEdgeImageKey;

@dynamic edgeImage;

-(void)setEdgeImage:(CGRect)rect
{
    objc_setAssociatedObject(self, &UIEdgeImageKey, NSStringFromCGRect(rect), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
    UIImageView * imageView = [[UIImageView alloc]initWithFrame:rect];
    imageView.image = self.image;
    [self addSubview:imageView];
    self.image = nil;
}

-(CGRect)edgeImage
{
    NSString * string = objc_getAssociatedObject(self, &UIEdgeImageKey);
    CGRect rect = CGRectFromString(string);
    return rect;
}

@end
